import turtle

def move_forward():
    t.forward(50)

def turn_left():
    t.left(45)

t = turtle.Turtle()
screen = turtle.Screen()

screen.listen()  # 开始监听事件
screen.onkey(move_forward, "Up")  # 按上键移动
screen.onkey(turn_left, "Left")  # 按左键旋转

turtle.done()